const service = require('../service/goods.service')

class GoodsController{
  async inser(ctx,next){
    const goods = ctx.request.body;
    const result =await service.inser(goods);
    ctx.body = result;
    await next();
  }
  
  async user_buy_goods(ctx,next){
    let {account} = ctx.user;
    let {iid,num} = ctx.request.body;
    const result = await service.user_buy_goods(account,iid,num);
    ctx.body = result;
    await next();
  }

  async user_search_goods(ctx,next){
    const{account} = ctx.user;
    console.log(account);
    const result = await service.user_search_goods(account);
    ctx.body = {
      account,result
    };
    await next();
  }
}

module.exports = new GoodsController();